package iscript.gameFramework.IsoEngine.display 
{
	import flash.display.Sprite;
	import flash.geom.Vector3D;
	import iscript.gameFramework.IsoEngine.data.IsoConfig;
	public class IsoGrid extends Sprite
	{
		
		private var _cellSize:Number;
		
		/**
		 *  视图Top角度
		 *  看到的轴线
		 *   x轴 和 z 轴， 
		 *   x轴是 宽度
		 *   z轴是 长度
		 *   Y轴是 高度
		 */   
		
		public function IsoGrid() 
		{
			_cellSize = IsoConfig.IsoGridSize;
		}
		 
		 
		public function setGridSize(widthX:uint, lengthZ:uint, heightY:uint=0):void {
			for (var i:int = numChildren - 1; i >= 0; i--)
			{
				removeChildAt(i);
			}
		    for (var j:int = 0; j <widthX ; j++) 
			{
				for (var k:int = 0; k <lengthZ; k++) 
				{
					 var  grid:IsoTileGrid = new IsoTileGrid(_cellSize);
						  grid.position = new Vector3D(j*_cellSize,heightY,k*_cellSize);
					      addChild(grid);
				}
			}
		}
			
		public function get cellSize():Number 
		{
			return _cellSize;
		}
		
		public function set cellSize(value:Number):void 
		{
			if (value < 2) throw new Error("格子大小不能2");
			_cellSize = value;
		}
		 
		 
		 
		 
		 
		 
	}

}